package com.myosw.quartz;


import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.myosw.cache.common.SearchlogEhCache;
import com.myosw.cache.common.VisitlogEhCache;
import com.myosw.dao.SearchlogDao;
import com.myosw.dao.VisitlogDao;
import com.myosw.jdbc.common.DBManager;

public class VisitlogJob implements Job {

	private static Logger _log = LoggerFactory.getLogger(VisitlogJob.class);
	@Override
	public void execute(JobExecutionContext jobcontext) throws JobExecutionException {
		_log.info("**********"+jobcontext.getJobDetail().getKey().getName()+"执行访问日志的存储");
		
		Object[][] objects=VisitlogEhCache.getlog();
		if (objects!=null) {
			VisitlogDao visitlogDao= new VisitlogDao();
			visitlogDao.save(objects);
			VisitlogEhCache.remove();
		}
		
		//关闭数据库链接
		DBManager.closeConnection(); //释放数据库连接到连接池中
	}

}
